#pragma once
#ifndef AXIS_H
#define AXIS_H
#include <string>
#include <vector>
#include <map>
#include <boost/serialization/access.hpp>

namespace LightChart
{
    class Chart;
    class Axis {
	public:
        Axis(Chart * owner) : min(0.), max(0.), tics(1.), scale(1.), label(std::string("")), owner(owner) {}
        void calculateDefaultParams();
        void set_min(double m) { min = m; }
        void set_max(double m) { max = m; }
        void set_tics(double t) { tics = t; }
        void set_scale(double s) { scale = s; }
        void set_label(const std::string& l) { label = l; }
        double get_min() const { return min; }
        double get_max() const { return max; }
        double get_tics() const { return tics; }
        double get_scale() const { return scale; }
        const std::string & get_label() const { return label; }
        Chart * get_owner() const { return owner; }
    private:
        double min;
        double max;
        double tics;
        double scale;
        std::string label;
        Chart * owner;
        friend class boost::serialization::access;
        template<class Archive> void serialize(Archive & ar, const unsigned int version);
    };
    template <class Archive> inline void Axis::serialize(Archive & ar, const unsigned int) {
        ar & min;
        ar & max;
        ar & tics;
        ar & scale;
        ar & label;
    }
}
namespace boost {
namespace serialization {
template <class Archive>
inline void save_construct_data (Archive & ar, const LightChart::Axis * axis, const unsigned int) {
    LightChart::Chart * owner = axis->get_owner();
    ar << owner;
}
template<class Archive>
inline void load_construct_data(Archive & ar, LightChart::Axis * axis, const unsigned int) {
    LightChart::Chart * chart;
    ar >> chart;
    ::new(axis)LightChart::Axis(chart);
}
}
}
#endif // AXIS_H
